<html  lang="pt-br">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" type="visao/css/image/x-icon" href="imagens/favicon1.ico" />
<link rel="stylesheet" href="/visao/css/estilo.css" type="text/css" media="all" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="visao/js/jquery-1.2.6.pack.js" type="text/javascript"></script>
<script src="visao/js/jquery.maskedinput-1.1.4.pack.js" type="text/javascript" ></script>
    <script type="text/javascript">$(document).ready(function(){
    	$("#cpf").mask("999.999.999-99");
        $("#nomeCliente").focus();
        $("#telefone").mask("(99)9999-9999");
        $('.relatorio tbody tr').hover(				
            function(){$(this).css("background","#C0C0C0");},
            function(){$(this).css("background","");}
        );

    });</script>

<style type="text/css">
<!--
.style1 {color: #333333}
-->
</style>
</head>
<body>
    <?php
    if ($_GET["comum"] == "cadNewCliente")
    {
    ?>   
      <h1 align="center">Cadastro de Clientes</h1>
      <p>&nbsp;</p>
     <form action="/" method="post">
      <table width="600" border="0" cellspacing="10" cellpadding="0">
        <tr>
        <td width="64"><div align="right"><span class="style1">Nome:</span></div></td>
          <td width="227"><label>
          <input type="hidden" name="operacao" value="cadCliente" />
          <input type="text" name="nomeCliente" id="nomeCliente" required="required"  size="40" maxlength="99"/>
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">CPF:</span></div></td>
          <td><input type="text" name="cpf" id="cpf"  required="required" maxlength="19"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Telefone:</span></div></td>
          <td><input type="text" name="telefoneCliente" size="12" id="telefone"  /></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Rua/Linha:</span></div></td>
          <td><input type="text" name="ruaCliente" id="ruaCliente"  maxlength="99"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Numero/Km:</span></div></td>
          <td><input name="numCliente" type="text" id="numCliente" size="5" maxlength="99"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Bairro:</span></div></td>
          <td><input type="text" name="bairroCliente" id="bairroCliente"  maxlength="99"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Cidade:</span></div></td>
          <td><input type="text" name="cidadeCliente" id="cidadeCliente" size="40"  maxlength="99"/></td>
        </tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="cadastraCliente" id="cadastraCliente" value="Cadastrar" />  </td>
        </tr>
      </table>
         </form>
      <?php
    }
    if ($_GET["comum"] == "cadCliente")
      {
           $numClientes = mysql_num_rows(getCliente());
           $clientes = getCliente();
      ?>
      <form action="/" method="GET" >
          <input type="hidden" name="comum" value="cadNewCliente" />
          <input  type="submit" value="Novo"/>
      </form>
      <fieldset><legend>Clientes cadastrados</legend>
      <table class="relatorio" width="940">
          <thead>
              <tr>
                  <th>Nome</th>
                  <th>CPF</th>
                  <th>Endereço</th>
                  <th>Número/Km</th>
                  <th>Bairro</th>
                  <th>Cidade</th>
                  <th>Telefone</th>
                  <th>Alterar</th>
              </tr>
          </thead>
          <tbody>
          <?php
          for ($i=0;$i<$numClientes;$i++){
              mysql_data_seek($clientes, $i);
              $arrayClientes = mysql_fetch_array($clientes);
                echo '<tr>';
            echo '<td>'.$arrayClientes["nome"].'</td>';
            echo '<td>'.$arrayClientes["cpf"].'</td>';
            echo '<td>'.$arrayClientes["rua"].'</td>';
            echo '<td>'.$arrayClientes["numero"].'</td>';
            echo '<td>'.$arrayClientes["bairro"].'</td>';
            echo '<td>'.$arrayClientes["cidade"].'</td>';
            echo '<td>'.$arrayClientes["telefone"].'</td>';
            echo '<td><a href="/?comum=alterarCliente&id='.$arrayClientes["id"].'">Alterar</a></td>';
                echo '</tr>';
          }
          ?>
          </tbody>
      </table></fieldset>
      <?php       
      }
       if ($_GET["comum"] == "relatorioCliente")
      {
           $numClientes = mysql_num_rows(getCliente());
           $clientes = getCliente();
      ?>
      <form action="xml/clienteCadastrado" method="POST" target="_blank">
          <input type="hidden" name="operacao" value="relatorioCliente" />
          <input type="hidden" name="idEmpresa" value="<?php echo $_SESSION["idEmpresa"]; ?>" />
          <input  type="submit" value="Baixar"/>
      </form>
      <p>&nbsp;</p>
      <table class="relatorio" width="950">
          <thead>
              <tr>
                  <th>Nome</th>
                  <th>CPF</th>
                  <th>Endereço</th>
                  <th>Número/Km</th>
                  <th>Bairro</th>
                  <th>Cidade</th>
                  <th>Telefone</th>
              </tr>
          </thead>
          <tbody>
          <?php
          for ($i=0;$i<$numClientes;$i++){
              mysql_data_seek($clientes, $i);
              $arrayClientes = mysql_fetch_array($clientes);
                echo '<tr>';
            echo '<td>'.$arrayClientes["nome"].'</td>';
            echo '<td>'.$arrayClientes["cpf"].'</td>';
            echo '<td>'.$arrayClientes["rua"].'</td>';
            echo '<td>'.$arrayClientes["numero"].'</td>';
            echo '<td>'.$arrayClientes["bairro"].'</td>';
            echo '<td>'.$arrayClientes["cidade"].'</td>';
            echo '<td>'.$arrayClientes["telefone"].'</td>';
                echo '</tr>';
          }
          ?>
          </tbody>
      </table>
      <?php       
      }
    if ($_GET["comum"] == "alterarCliente")
    {
        include 'modelo/modeloCliente.php';
        $id = addslashes($_GET["id"]);
        settype($id, 'integer');
        $cliente = mysql_fetch_array(getDadosCliente($id));
    ?>    
    
      <h1>Alterar cliente</h1>
      <p>&nbsp;</p>
     <form action="/" method="POST">
          <input type="hidden" name="operacao" value="alterarCliente" />
          <input type="hidden" name="id" value="<?php echo $id;?>" />
      <table width="300" border="0" cellspacing="10" cellpadding="0">
        <tr>
        <td width="64"><div align="right"><span class="style1">Nome:</span></div></td>
          <td width="227"><label>
            <input type="text" name="nome" id="nomeCliente" value="<?php echo $cliente["nome"];?>" size="40" maxlength="99"/>
          </label></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">CPF:</span></div></td>
          <td><input type="text" name="cpf" id="cpf"  value="<?php echo $cliente["cpf"];?>"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Telefone:</span></div></td>
          <td><input type="text" name="telefone" size="12" id="telefone"  value="<?php echo $cliente["telefone"];?>"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Rua/Linha:</span></div></td>
          <td><input type="text" name="rua" id="ruaCliente"  value="<?php echo $cliente["rua"];?>" maxlength="99"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Numero/Km:</span></div></td>
          <td><input name="numero" type="text" id="numCliente" size="5" value="<?php echo $cliente["numero"];?>" maxlength="99"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Bairro:</span></div></td>
          <td><input type="text" name="bairro" id="bairroCliente" value="<?php echo $cliente["bairro"];?>"  maxlength="99"/></td>
        </tr>
        <tr>
          <td><div align="right"><span class="style1">Cidade:</span></div></td>
          <td><input type="text" name="cidade" id="cidadeCliente" value="<?php echo $cliente["cidade"];?>"  size="40" maxlength="99"/></td>
        </tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="cadastraCliente" id="cadastraCliente" value="Alterar" />  </td>
        </tr>
      </table>
         </form>
      <?php
    }
      ?>
</body>
</html>